package com.guangdujs.kis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.guangdujs.common.annotation.Log;
import com.guangdujs.common.core.controller.BaseController;
import com.guangdujs.common.core.domain.AjaxResult;
import com.guangdujs.common.enums.BusinessType;
import com.guangdujs.kis.domain.TUser;
import com.guangdujs.kis.service.ITUserService;
import com.guangdujs.common.utils.poi.ExcelUtil;
import com.guangdujs.common.core.page.TableDataInfo;

/**
 * 系统用户信息Controller
 * 
 * @author kis
 * @date 2022-11-01
 */
@RestController
@RequestMapping("/kis/User")
public class TUserController extends BaseController
{
    @Autowired
    private ITUserService tUserService;

    /**
     * 查询系统用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('kis:TUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(TUser tUser)
    {
        startPage();
        List<TUser> list = tUserService.selectTUserList(tUser);
        return getDataTable(list);
    }

    /**
     * 导出系统用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('kis:TUser:export')")
    @Log(title = "系统用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TUser tUser)
    {
        List<TUser> list = tUserService.selectTUserList(tUser);
        ExcelUtil<TUser> util = new ExcelUtil<TUser>(TUser.class);
        util.exportExcel(response, list, "系统用户信息数据");
    }

    /**
     * 获取系统用户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kis:TUser:query')")
    @GetMapping(value = "/{fuserid}")
    public AjaxResult getInfo(@PathVariable("fuserid") Long fuserid)
    {
        return AjaxResult.success(tUserService.selectTUserByFuserid(fuserid));
    }

    @GetMapping(value = "/getCount")
    public AjaxResult selectTUserCount(){
        int userCount = tUserService.selectTUserCount();
        return AjaxResult.success(userCount);
    }

}
